Skip to content

Drop max_inbound_htlc_value_in_flight_percent_of_channel #878

Merged
tnull merged 1 commit intolightningdevkit:mainfrom
jkczyz:2026-04-lsp-max-in-flight
Apr 29, 2026
Merged

Drop max_inbound_htlc_value_in_flight_percent_of_channel #878
tnull merged 1 commit intolightningdevkit:mainfrom
jkczyz:2026-04-lsp-max-in-flight

Conversation

@jkczyz
Copy link
Copy Markdown
Contributor

@jkczyz jkczyz commented Apr 17, 2026

The max_inbound_htlc_value_in_flight_percent_of_channel config setting was used when acting as an LSPS2 service in order to forward the initial payment. However, upstream divided the config setting into two for announced and unannounced channels, the latter defaulting to 100%.

Based on #874.

@ldk-reviews-bot
Copy link
Copy Markdown

ldk-reviews-bot commented Apr 17, 2026

👋 I see @valentinewallace was un-assigned.
If you'd like another reviewer assignment, please click here.

@jkczyz jkczyz marked this pull request as draft April 17, 2026 21:55
@tnull tnull added this to the 0.8 milestone Apr 20, 2026
@jkczyz jkczyz force-pushed the 2026-04-lsp-max-in-flight branch 2 times, most recently from 54b2aa3 to e09fd86 Compare April 23, 2026 23:03
@jkczyz jkczyz force-pushed the 2026-04-lsp-max-in-flight branch from e09fd86 to e8f3575 Compare April 27, 2026 17:51
Copy link
Copy Markdown
Contributor

@tankyleo tankyleo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you I am excited to land this PR soon, a few nits

Comment thread src/liquidity.rs
.unannounced_channel_max_inbound_htlc_value_in_flight_percentage,
100
);
debug_assert!(config.accept_forwards_to_priv_channels);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can we add a debug_assert here on announce_for_forwarding = false ? IIUC right now we inherit announce_for_forwarding = false here because of the default in rust-lightning, but would be good to confirm this here I think.

This is to make sure that the 100% cap actually gets applied to the channel opened by the LSPS2 service.

Comment thread src/builder.rs
Comment on lines -1661 to -1664
// If we act as an LSPS2 service, set the HTLC-value-in-flight to 100% of the channel value
// to ensure we can forward the initial payment.
user_config.channel_handshake_config.max_inbound_htlc_value_in_flight_percent_of_channel =
100;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To confirm here I don't think setting 100% here would have helped as that maximum only applies to the inbound HTLCs on that channel. To make sure that 100% of the value can be allocated to outbound HTLCs from the LSP's perspective as the comment describes, the user needs to set their max_inbound to 100%.

So seems to me the intention of the code did not match the comment ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... yeah it does seem that way.

Comment thread src/lib.rs
let mut user_config = default_user_config(&self.config);
user_config.channel_handshake_config.announce_for_forwarding = announce_for_forwarding;
user_config.channel_config = (channel_config.unwrap_or_default()).clone().into();
// We set the max inflight to 100% for private channels.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: similar here, would it be worth adding a debug_assert to guard against any changes away from this behavior ?

Comment thread src/event.rs
accept_underpaying_htlcs: Some(true),
..Default::default()
}),
..Default::default()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: as elsewhere, maybe a quick debug_assert here on the 100% value ? Up to @tnull

@jkczyz jkczyz force-pushed the 2026-04-lsp-max-in-flight branch from e8f3575 to 4fda093 Compare April 28, 2026 16:14
jkczyz added a commit to jkczyz/ldk-node that referenced this pull request Apr 28, 2026
Per review feedback on PR lightningdevkit#878. The forwarding behavior for LSPS2 channels
relies on LDK's default of 100% for the unannounced-channel inbound
HTLC value-in-flight cap. Catch upstream changes to that default with
debug asserts at the three sites that depend on it.

Generated with assistance from Claude Code.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor Author

@jkczyz jkczyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed nits

Comment thread src/builder.rs
Comment on lines -1661 to -1664
// If we act as an LSPS2 service, set the HTLC-value-in-flight to 100% of the channel value
// to ensure we can forward the initial payment.
user_config.channel_handshake_config.max_inbound_htlc_value_in_flight_percent_of_channel =
100;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... yeah it does seem that way.

The max_inbound_htlc_value_in_flight_percent_of_channel config setting
was used when acting as an LSPS2 service in order to forward the initial
payment. However, upstream divided the config setting into two for
announced and unannounced channels, the latter defaulting to 100%.
@jkczyz jkczyz force-pushed the 2026-04-lsp-max-in-flight branch from 20bae9a to d93bb39 Compare April 29, 2026 16:12
@jkczyz jkczyz marked this pull request as ready for review April 29, 2026 16:13
@jkczyz jkczyz requested review from tankyleo and tnull and removed request for valentinewallace April 29, 2026 16:13
Copy link
Copy Markdown
Collaborator

@tnull tnull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@tnull tnull merged commit 16eaa6f into lightningdevkit:main Apr 29, 2026
28 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants